/**
 *Copyright(c) HNA SYSTEMS Co., LTD
 *
 *@date 2013-7-18
 * 	
 *Original Author: 郑兴(zhengxing)
 *
 *ChangeLog
 *
 */
package com.hnas.sys.core.spring;

import java.io.IOException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.Resource;

/**
 * Class Name:SpringBeanUtil
 * Used for look up java bean
 * @author nl_tan
 *
 */
public final class SpringBeanUtil {
	private static final Logger log = LoggerFactory.getLogger(SpringBeanUtil.class);
	
	/**
	 * 
	 * @param id to set
	 * @return java bean
	 */
	public static Object lookup(String id) {
		Object obj=ApplicationContextFactory.getApplicationContext().getBean(id);
		return obj;
	}
	
	/**
	 * 
	 * @param path ex: "classpath:seatmap/file/*.txt"
	 * @return Resource[] local
	 */
	public static Resource[] findFiles(String path) {
		Resource[] res;
		try {
			res = ApplicationContextFactory.getApplicationContext().getResources(path);
			return res;
		} catch (IOException e) {
			log.error(e.getMessage());
		}
		return null;
	}
	
	
}
